import { defineStore } from 'pinia'

export const patientStore = defineStore('patient', {
  state: () => ({
    info: {
      name: '',
      idCard: '',
      sex: '',
      phone: '',
      relation: '',
      birthday: '',
      address: '',
      addressDetail: '',
      addressLng: '',
      addressLat: ''
    }
  }),
  actions: {
    setPatientName (data) {
      this.info.name = data
    },
    setPatientIdCard (data) {
      this.info.name = data
    },
    setPatientInfo (data) {
      this.info = data
    },
    setPatientRelation (data) {
      this.info.relation = data
    },
    setPatientSex (data) {
      this.info.sex = data
    },
    setPatientBirthday (data) {
      this.info.birthday = data
    },
    setPatientAddress (data) {
      this.info.address = data.address
      this.addressLng = data.addressLng
      this.addressLat = data.addressLat
    }
  },
  persist: {
    // 保存的位置
    enabled: true,
    storage: sessionStorage // localstorage
  }
})
